﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SAM_Edu.form;
using SAM_Edu.control;
using SAM_Edu.entity;
using System.IO;
using System.Threading;

namespace SAM_Edu
{
    public partial class frmMain : Form
    {
        string username;

        Accounts account;
        public frmMain()
        {
            InitializeComponent();
        }
        static int uid = 0;
        static string uusername = "";
        public frmMain(Accounts a,User u)
        {
            InitializeComponent();
            uid = u.UID;
            uusername = a.Username;
       //     createUserToolStripMenuItem.Enabled = Convert.ToBoolean( (val & 0x0000000000001)  != 0);
          
        }
        private void createUserToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCreateUser CU = new frmCreateUser();
            CU.MdiParent = this;
            CU.StartPosition = FormStartPosition.Manual;
            CU.Location = new System.Drawing.Point(10, 10);
            CU.Show();
        }

        private void manageUserPhotosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmManageAccessRights MR = new frmManageAccessRights();
            MR.MdiParent = this;
            MR.StartPosition = FormStartPosition.Manual;
            MR.Location = new System.Drawing.Point(10, 10);
            MR.Show();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
          
            frmStartUp CU = new frmStartUp();

            CU.MdiParent = this;
            CU.StartPosition = FormStartPosition.Manual;
            CU.Location = new System.Drawing.Point(10, 10);
            CU.Show();

          

        }
      

        public Image byteArrayToImage(byte[] byteArrayIn)
        {
            MemoryStream ms = new MemoryStream(byteArrayIn);
            Image returnImage = Image.FromStream(ms);
            return returnImage;
        }



        private void loginToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmLogon LO = new frmLogon();
            LO.MdiParent = this;
            LO.StartPosition = FormStartPosition.Manual;
            LO.Location = new System.Drawing.Point(10, 10);
            LO.Show();
        }

        private void updateUsersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Accounts acc = UpdateUser.getAccountInformation(uusername);
            User user = UpdateUser.getUserInformation(uid);
            frmUpdateUser UU = new frmUpdateUser(acc,user);
            UU.MdiParent = this;
            UU.StartPosition = FormStartPosition.Manual;
            UU.Location = new System.Drawing.Point(10, 10);
            UU.Show();


        }

        private void companyLogo_Click(object sender, EventArgs e)
        {

        }

        private void companyLogo_BackgroundImageChanged(object sender, EventArgs e)
        {
            
        }
        public ulong getUserRights(string username)
        {
            ulong value = ManageFeatures.requestUserRights(username);
            return value;
        }

       
      

     

    }
}
